﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using BOSS.Framework.Search;
using BOSS.Framework.Search.Context;
using BOSS.Framework.Search.Result;
using BOSS.Domain.Products;
using BOSS.Dao.Products;

namespace BOSS.Service.Implements.Searchers
{
    public class ConsumptionRecordSearcher : ISearcher
    {
        /// <summary>
        /// 
        /// </summary>
        public IConsumptionRecordDao ConsumptionRecordDao { get; set; }

        #region ISearcher 成员

        /// <summary>
        /// 指示更新索引
        /// </summary>
        /// <param name="contentType"></param>
        /// <param name="actionType"></param>
        /// <param name="contentId"></param>
        /// <returns></returns>
        public bool Indicate(string contentType, ActionType actionType, int contentId)
        {
            return false;
        }

        public ISearchResult Search(ISearchContext context, string resultSchema)
        {
            int totalCount = 0;

            IList<ConsumptionRecord> results = this.ConsumptionRecordDao.SelectBySearch(context, out totalCount);

            SearchResult result = new SearchResult(context, totalCount, string.Empty);
            foreach (ConsumptionRecord item in results)
            {
                result.AddItem(new PropertyResultItem(item.Id, 1, item.SerialNumber, item));
            }
            return result;
        }

        #endregion
    }
}
